package com.zzyl.nursing.service.impl;

import cn.hutool.core.date.LocalDateTimeUtil;
import com.zzyl.nursing.dto.TimeSlotCount;
import com.zzyl.nursing.service.IMemberReservationService;
import com.zzyl.nursing.mapper.MemberReservationMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.List;

/**
 * 预约信息Service业务层处理
 *
 * @author ruoyi
 */
@Service
public class MemberReservationServiceImpl implements IMemberReservationService {

    @Autowired
    private MemberReservationMapper memberReservationMapper;


    /**
     * 查询当天取消预约数量
     *
     * @param userId 用户ID
     * @return 取消预约数量
     */
    @Override
    public Integer getCancelledReservationCount(Long userId) {
        // 获取当天开始和结束时间
        long time = System.currentTimeMillis();
        LocalDateTime startTime = LocalDateTimeUtil.of(time).toLocalDate().atStartOfDay();
        LocalDateTime endTime = startTime.plusDays(1);

        // 查询当天取消预约数量
        return memberReservationMapper.selectCancelledReservationCount(userId, startTime, endTime);
    }
}
